<template>
	<view>
		<view class="navigation">
			<view class="navigation_back" @tap="backref()">
				<uni-icons type="back" size="24" color="#fff"></uni-icons>
			</view>
			<view class="navigation_title">
				编辑地址
			</view>
			<view class="navigation_delete" @tap="deleteAddress()">
				删除
			</view>
		</view>
		<view class="address_con">
			<view class="address_item address_name">
				<view class="address_icon">
					<image src="../../../static/image/memberCenter/address_name.svg" mode=""></image>
				</view>
				<view class="address_input">
					<input type="text" placeholder="请输入您的姓名" placeholder-class="placeholder">
				</view>
			</view>
			<view class="address_item address_phone">
				<view class="address_icon">
					<image src="../../../static/image/memberCenter/address_phone.svg" mode=""></image>
				</view>
				<view class="address_input">
					<input type="text" placeholder="请输入电话号码">
				</view>
			</view>
			<view class="address_item address_location">
				<view class="address_icon">
					<image src="../../../static/image/memberCenter/address_location.svg" mode=""></image>
				</view>
				<view class="address_input">
					<input type="text" placeholder="请选择地址">
				</view>
				<view class="address_more">
					<uni-icons type="forward" size="16"></uni-icons>
				</view>
			</view>
			<view class="address_item address_building">
				<view class="address_icon">
					<image src="../../../static/image/memberCenter/address_build.svg" mode=""></image>
				</view>
				<view class="address_input">
					<input type="text" placeholder="大楼名,如7栋">
				</view>
			</view>
			<view class="address_item address_plate">
				<view class="address_icon">
					<image src="../../../static/image/memberCenter/address_plate.svg" mode=""></image>
				</view>
				<view class="address_input">
					<input type="text" placeholder="门牌号,如101">
				</view>
			</view>
			<view class="address_item address_default">
				<view class="address_item_label">
					设为默认收货地址
				</view>
				<label class="radio">
					<radio checked="true" color="#2588FF" />
				</label>
			</view>

			<view class="address_add" @tap="sureAddress()">
				<button>确定</button>
			</view>
		</view>

		<view class="mask" v-if="deleteFlag == true"></view>
		<view class="delete_mask" v-if="deleteFlag == true">
			<view class="delete_title">
				确定要删除地址吗？
			</view>
			<view class="delete_btns">
				<view class="delete_cancel" @tap="cancelDelete()">
					取消
				</view>
				<view class="delete_sure" @tap="sureDelete()">
					确定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deleteFlag: false
			};
		},
		methods: {
			backref() {
				uni.navigateBack({
					delta: 1
				})
			},
			deleteAddress() {
				this.deleteFlag = true;
			},
			sureAddress() {
				uni.navigateTo({
					url: '/pages/memberCenter/address/address'
				})
			},

			cancelDelete() {
				this.deleteFlag = false;
			},

			sureDelete() {
				this.deleteFlag = false;
				uni.showToast({
					title: "删除成功",
					icon: 'none',
					duration:2000
				})
				setTimeout(()=>{
					uni.navigateTo({
						url: '/pages/memberCenter/address/address'
					})
				},2000)
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F4F4F4;
	}

	.navigation {
		width: 100%;
		height: 260rpx;
		background-color: #2588FF;
		padding: 60rpx 24rpx 0;
		text-align: center;
		position: relative;

		.navigation_back {
			position: absolute;
			top: 60rpx;
		}

		.navigation_title {
			color: #fff;
			font-size: 36rpx;
		}

		.navigation_delete {
			position: absolute;
			right: 32rpx;
			top: 65rpx;
			color: #fff;
			font-size: 32rpx;
		}
	}

	.address_con {
		position: relative;
		z-index: 2;
		padding: 40rpx 32rpx 180rpx;
		border-radius: 32rpx 32rpx 0 0;
		background-color: #F4F4F4;
		margin-top: -100rpx;

		.address_item {
			position: relative;
			display: flex;
			align-items: center;
			height: 100rpx;
			background-color: #fff;
			border-radius: 12rpx;
			margin-bottom: 24rpx;
			padding: 0 24rpx;

			.address_icon {
				width: 40rpx;
				display: flex;
				justify-content: center;

				image {
					width: 40rpx;
					height: 42rpx;
				}
			}

			.address_input {
				margin-left: 30rpx;

				input {
					color: #333;
					font-size: 26rpx;
					width: 400rpx;

					&.placeholder {
						color: #666;
					}
				}
			}

			.address_more {
				position: absolute;
				right: 24rpx;
			}

			.address_item_label {
				font-size: 30rpx;
				color: #2E343A;
			}

			.radio {
				position: absolute;
				right: 24rpx;
			}
		}
	}

	.address_add {
		position: fixed;
		left: 0;
		bottom: 50rpx;
		width: 100%;
		padding: 0 24rpx;

		button {
			height: 80rpx;
			background-color: #2588FF;
			color: #fff;
			font-size: 28rpx;
			font-weight: 700;
			border: 0;
			line-height: 80rpx;
			border-radius: 80rpx;
		}
	}


	.mask {
		position: fixed;
		z-index: 5;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
	}

	.delete_mask {
		position: fixed;
		z-index: 5;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 610rpx;
		height: 300rpx;
		background-color: #fff;
		padding-top: 80rpx;
		border-radius: 12rpx;

		.delete_title {
			text-align: center;
			color: #2E343A;
			font-size: 32rpx;
			font-weight: 500;
		}

		.delete_btns {
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 96rpx;
			border-top: 1rpx solid #ccc;
			display: flex;

			.delete_cancel {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 50%;
				height: 96rpx;
				color: #2E343A;
				border-right: 1rpx solid #ccc;
			}

			.delete_sure {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 50%;
				height: 96rpx;
				color: #2588FF;
			}
		}
	}
</style>